﻿-- 创建角色对应的菜单
CREATE PROCEDURE [dbo].[proc_AppRolesMenu_Insert]
	(
	@RoleName nvarchar(50),
	@Description nvarchar(265),
	@Sort int,
	@RoleId int,
	@Memus nvarchar(2000)
	)
AS
begin
	Update aspnet_Roles Set RoleName=@RoleName,Description=@Description,Sort=@Sort Where RoleId=@RoleId
	Delete AppRolesMenu Where RoleId=@RoleId
	Declare @i int
	Set @i=0
	while(@i<len(@Memus))
	begin
		Insert Into AppRolesMenu(RoleId,MenuId)Values(@RoleId, substring(@Memus,@i,charindex(',',@Memus,@i)-@i))
		Set @i=charindex(',',@Memus,@i)+1
	end
end
	RETURN
